<template>
  <div class="card">
    <div class="moving-element"></div>
    <div class="element">
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
// 模块引入
//import { ref } from 'vue'
defineOptions({
  // 组件名称
  name: 'CardComp',
  // 继承透传，是否继承没在子组件声明的父组件的属性
  inheritAttrs: true
})
</script>

<style scoped lang="scss">
.card {
  background: #000;
  position: relative;
  width: 400px;
  height: 200px;
  padding: 4px;
  margin: 50px;
  border-radius: 30px;
  overflow: hidden;
  .moving-element {
    position: absolute;
    top: 0;
    left: 40px;
    width: 80px;
    height: 80px;
    background-image: radial-gradient(#cbacf9 40%, transparent 80%);
    transform: translate(-40px, -40px);
    animation: moveAround 8s linear infinite;
  }
  .element {
    width: 100%;
    height: 100%;
    background: rgba(9, 9, 11, 0.38);
    border: 1px solid rgb(30, 41, 59);
    border-radius: 30px;
    backdrop-filter: blur(24px);
    box-sizing: border-box;
  }
}
@keyframes moveAround {
  0% {
    left: 40px;
    top: 0px;
  }
  28.93% {
    left: 360px;
    top: 0px;
  }
  33.99% {
    left: 400px;
    top: 40px;
  }
  44.82% {
    left: 400px;
    top: 160px;
  }
  49.88% {
    left: 360px;
    top: 200px;
  }
  78.81% {
    left: 40px;
    top: 200px;
  }
  83.87% {
    left: 0px;
    top: 160px;
  }
  94.7% {
    left: 0px;
    top: 40px;
  }
  100% {
    left: 40px;
    top: 0px;
  }
}
</style>
